package net.lab1024.sa.admin.module.cfs.service;

import java.util.List;
import net.lab1024.sa.admin.module.cfs.dao.CfsDataNbUsermonitorinfoDao;
import net.lab1024.sa.admin.module.cfs.domain.entity.CfsDataNbUsermonitorinfo;
import net.lab1024.sa.admin.module.cfs.domain.form.CfsDataNbUsermonitorinfoAddForm;
import net.lab1024.sa.admin.module.cfs.domain.form.CfsDataNbUsermonitorinfoQueryForm;
import net.lab1024.sa.admin.module.cfs.domain.form.CfsDataNbUsermonitorinfoUpdateForm;
import net.lab1024.sa.admin.module.cfs.domain.vo.CfsDataNbUsermonitorinfoVO;
import net.lab1024.sa.base.common.util.SmartBeanUtil;
import net.lab1024.sa.base.common.util.SmartPageUtil;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 联网设备NB类型表 Service
 *
 * @Author cfsjiazy
 * @Date 2025-09-15 09:35:31
 * @Copyright  
 */

@Service
public class CfsDataNbUsermonitorinfoService {

    @Resource
    private CfsDataNbUsermonitorinfoDao cfsDataNbUsermonitorinfoDao;

    /**
     * 分页查询
     */
    public PageResult<CfsDataNbUsermonitorinfoVO> queryPage(CfsDataNbUsermonitorinfoQueryForm queryForm) {
        Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
        List<CfsDataNbUsermonitorinfoVO> list = cfsDataNbUsermonitorinfoDao.queryPage(page, queryForm);
        return SmartPageUtil.convert2PageResult(page, list);
    }

    /**
     * 添加
     */
    public ResponseDTO<String> add(CfsDataNbUsermonitorinfoAddForm addForm) {
        CfsDataNbUsermonitorinfo cfsDataNbUsermonitorinfoEntity = SmartBeanUtil.copy(addForm, CfsDataNbUsermonitorinfo.class);
        cfsDataNbUsermonitorinfoDao.insert(cfsDataNbUsermonitorinfoEntity);
        return ResponseDTO.ok();
    }

    /**
     * 更新
     *
     */
    public ResponseDTO<String> update(CfsDataNbUsermonitorinfoUpdateForm updateForm) {
        CfsDataNbUsermonitorinfo cfsDataNbUsermonitorinfoEntity = SmartBeanUtil.copy(updateForm, CfsDataNbUsermonitorinfo.class);
        cfsDataNbUsermonitorinfoDao.updateById(cfsDataNbUsermonitorinfoEntity);
        return ResponseDTO.ok();
    }

    /**
     * 批量删除
     */
    public ResponseDTO<String> batchDelete(List<Long> idList) {
        if (CollectionUtils.isEmpty(idList)){
            return ResponseDTO.ok();
        }

        cfsDataNbUsermonitorinfoDao.deleteBatchIds(idList);
        return ResponseDTO.ok();
    }

    /**
     * 单个删除
     */
    public ResponseDTO<String> delete(Long id) {
        if (null == id){
            return ResponseDTO.ok();
        }

        cfsDataNbUsermonitorinfoDao.deleteById(id);
        return ResponseDTO.ok();
    }
}
